<?php
header("Content-Type: text/html; charset=utf-8");
include('db-conn.php');
session_start();
$lifeTime = 24 * 3600;
setcookie(session_name(), session_id(), time() + $lifeTime, "/");
$user=$_POST['name'];
$pass=$_POST['password'];

//ini_set('session.cookie_lifetime','3600');
//setcookie($_COOKIE['name'],$_COOKIE['value'],time()+99*365*24*3600);
if (isset($user) && isset($pass)){
$cha="select * from jiuye.user where name='$user';";
	echo $cha;
$a=mysqli_fetch_assoc(mysqli_query($conn,$cha));
		if($user == $a["name"] && $pass == $a["password"]){
			echo "<script>alert('登录成功')";
			$_SESSION['name']=$user;
			$_SESSION['pass']=$pass;
			$_SESSION['sname']=$a['s_name'];
			
			//setcookie('user',$user);
			header("location:list.php");
		}else{
			echo "<script>alert('用户名或密码错误');window.location.href='index.php';</script>";
		}

	mysqli_close($conn);
	//header("location:zhuce.html");
}else{
	echo "<script>alert('请输入用户名或密码');window.location.href='index.html';</script>";
}
?>


